home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
176-200
/
disk_176
/
hypernet
/
hypernet.for
< prev
next >
Wrap
Text File
|
1992-05-06
|
7KB
|
244 lines
C compilation:
C f77 -k -h -u -* HyperNet.for
C link:
C f77l -y hypernet amiga.sub
C
C SIMPLE-MINDED HYPERTEXT ON TERMINALS
C DRIVEN OFF A FILE OF FORM
C +NODENAME
C $(ANY ACTION COMMAND TO BE SPAWNED) (or start with & for spawn/nowait)
C >NEXT-NODE-1
C >NEXT-NODE-2
C >NEXT-NODE-3
C ...
C REPEATED FOR LOTS OF NODES.
C By Glenn Everhart
C 25 Sleigh Ride Rd
C Glen Mills PA 19342
C
C Public domain...use & enjoy.
C gce 9/3/1988
INTEGER*4 ISTAT,IFLG
Integer*4 ScrCnt
C USE LIB$SPAWN TO EMIT COMMANDS. SLOW BUT THIS IS A KLUDGE DEMO
C WHICH WILL BE A FIRST STEP ONLY.
INCLUDE DOS.INC
INTEGER*4 AMIGA
CHARACTER*128 CMDC
CHARACTER*1 CMD(128)
EQUIVALENCE (CMDC,CMD(1))
C ALLOWS US TO WORK WITH CHARS OF COMMAND PROGRAMMATICALLY
CHARACTER*1 FILRD(128)
CHARACTER*128 FILC
EQUIVALENCE (FILC,FILRD(1))
C ALLOWS READING LINES OF TEXT.
Character*128 FilNam
CHARACTER*128 CURNODE
CHARACTER*128 SUCCNODE(16)
C ALLOW UP TO 16 SUCCESSOR NODES.
C
C OPEN THE CONSOLE
C OPEN(UNIT=5,FILE='SYS$INPUT',CARRIAGECONTROL='NONE',
C 1 status='OLD')
C OPEN(UNIT=6,FILE='SYS$OUTPUT',CARRIAGECONTROL='NONE',
C 1 status='new')
C FORGET ABOUT FORTRASH CARRIAGE CONTROLS.
C SET UP CURRENT NODE AS "START"
IFLG=1
Call CPut('Compiled by Absoft Fortran 2.3',30)
call cclr
call cpos(1,1)
call cput('Enter filename of data file:',28)
call cget(filnam,IFNSZ)
call cpos(2,1)
call cput('Pause before menus [Y/N]:',25)
ipaus=0
call cget(filc,iii)
ScrCnt=0
if(filc(1:1).eq.'y'.or.filc(1:1).eq.'Y')ipaus=1
998 CONTINUE
CURNODE='+START' // CHAR(0)
1000 CONTINUE
C OPEN THE DATA FILE.
C MUST HAVE NODENAME START SOMEPLACE.
OPEN(1,FILE=FilNam(1:IFNSZ),ACCESS='Sequential',
1 FORM='FORMATTED',STATUS='OLD')
1050 CONTINUE
C READ THE DATA FILE UNTIL WE FIND CURRENT NODE DESIRED.
READ(1,100,END=9000)FILC
100 FORMAT(A)
If(Filc(1:1).ne.'+')goto 1050
IF(ICMPST(CURNODE,FILC).EQ.0)GOTO 1050
C GOT THE NODE.
C NOW READ THE COMMAND TO EXECUTE.
READ(1,100,END=9990)CMDC
ISUC=1
IF(CMDC(1:1).NE.'$'.and.CMDC(1:1).ne.'&'
1 .AND.CMDC(1:1).EQ.'>')THEN
ISUC=2
SUCCNODE(1)=CMDC
END IF
MXSUC=ISUC-1
DO 2000 I=ISUC,16
C AT MOST 16 SUCCESSOR NODES
READ(1,100,END=2020)FILC
IF(FILC(1:1).NE.'>')GOTO 2020
SUCCNODE(I)=FILC
MXSUC=MXSUC+1
2000 CONTINUE
2020 CONTINUE
CLOSE(UNIT=1)
C ALLOW EDITS OF HYPERTEXT FILE TO TAKE EFFECT NEXT TIME VIA CLOSE/REOPEN.
C NOTE WE CAN SPAWN/NOWAIT TO ALLOW MULTIPLE COMMANDS TO TAKE EFFECT.
C
C NOW ISSUE THE COMMAND. USE LIB$SPAWN HERE. A SLIGHT VARIATION WOULD
C REQUIRE USING BOSS AND HANDLE SWITCHING VIA COMMANDS TO BOSS TO FIRE
C UP THE APPLICATION. FOR NOW, DO IT VANILLA.
C spawn with wait if $ seen, with nowait if & seen in col 1.
IIV=0
C Absoft Fortran seems to have trouble firing off some commands
C directly, so fire off from a newcli, and use a short file in
C ram: to hold the actual command, whatever it may be.
C
C Also arrange for scratch file name to have 0-9 added so that
C the system will not have to re-use names before they have become
C freed. Kludge, but easier than a complete solution, which might
C involve something like ending via a transfer to a command file that
C will delete all tmp.jnk#? files in ram: that it can.
ScrCnt=Mod(ScrCnt+1,10)
filc='Ram:Tmp.Jnk'//char(ScrCnt+48) // char(0)
OPEN(2,FILE=filc)
REWIND 2
If(Cmdc(2:2).ne.'&')GoTo 228
C last-minute add-on
C if SECOND character of command line is &, then have an automatic
C ENDCLI generated after the user's command.
Write(2,222)Cmdc(3:127)
Write(2,227)
227 Format('Endcli')
228 Continue
WRITE(2,222)CMDC(2:127)
229 Continue
222 Format(A)
CLOSE (UNIT=2)
If(cmdc(1:1).ne.'$'.and.Cmdc(1:1).ne.'&')goto 224
filc='NEWCLI CON:0/0/600/190/Hypnet FROM ram:Tmp.Jnk'
1 // char(ScrCnt+48) // Char(0)
If(cmdc(1:1).eq.'&')filc='Newshell FROM ram:Tmp.Jnk' //
1 Char(ScrCnt+48) // Char(0)
ISTAT=AMIGA(EXECUTE,filc,IIV,IIV)
224 Continue
C STRIPS OFF THE CRUFT AT THE START AND FIRES IT UP.
C
C NOW DISPLAY THE MENU AND GO TRY AGAIN.
CALL CPOS(24,1)
If(Ipaus.eq.1)CALL CPUT('Return when ready for menu:',27)
If(Ipaus.eq.1)Call CGET(filc,iiii)
Call CCLR
C clear screen
Call CPOS(1,1)
C go to top left
If(Mxsuc.lt.1)goto 998
do 2500 i=1,MXSUC
write(filc(1:2),2501)i
2501 format(i2)
cmdc=filc(1:2)//' '//succnode(i)(2:76)
Call cpos(i,2)
Call CPUT(cmdc,78)
2500 Continue
C Now get his reply for selection. Do by number for the
C time being, since that's the simplest way to do it.
2504 Continue
cmdc=' '
Call CPOS(20,10)
C move to line 20, col 10
Call CPUT('Enter choice (number):',22)
Call CGET(cmdc,iii)
read(cmdc,2503,err=9990,end=9990)i
2503 Format(bn,I2)
C Edit this format if we allow more choices than 99 in the future
C Loop back if his reply is out of range for this.
If(i.eq.99)goto 998
If(i.eq.98)goto 9990
C restart on an input of 99
If(i.lt.0.or.i.gt.MXSUC) goto 2504
C Got a valid (apparently) choice.
C Make it the new current node and go back.
CURNODE=SUCCNODE(I)
Curnode(1:1)='+'
C Fix up with + in col 1 so we need not mask this stuff off.
GOTO 1000
9000 CONTINUE
CALL CCLR
CALL CPOS(6,4)
CALL CPUT('UNKNOWN NODE. RESTARTING.',25)
CLOSE(UNIT=1)
GOTO 998
9990 CONTINUE
Close(unit=1)
c be sure lun 1 is closed...safety.
STOP 'End HyperNet'
END
SUBROUTINE CGET(STRING,LEN)
C GET A CHARACTER STRING IN WITH ITS LENGTH
CHARACTER*80 STRING
INTEGER*4 LEN
READ(*,100)STRING
100 FORMAT(A)
DO 1 N=1,80
NN=81-N
IF(ICHAR(STRING(NN:NN)).GT.32)GOTO 2
1 CONTINUE
2 CONTINUE
LEN=NN
RETURN
END
SUBROUTINE CPUT(STRING,LEN)
C WRITE STRING OF LENGTH "LEN"
CHARACTER*128 STRING
INTEGER*4 LEN
WRITE(*,100)STRING(1:LEN)
100 FORMAT(A)
RETURN
END
SUBROUTINE CPOS(IR,IC)
C MOVE TO ROW IR, COL IC
INTEGER*4 IR,IC
CHARACTER*3 CR,CC
CHARACTER*1 IE
IE=CHAR(27)
WRITE(CR,1)IR
1 FORMAT(I3.3)
WRITE(CC,1)IC
WRITE(*,2)IE,CR,CC
2 FORMAT(A,'[',A,';',A,'H')
RETURN
END
SUBROUTINE CCLR
C CLEAR DISPLAY
CHARACTER*1 IE
IE=CHAR(27)
WRITE(*,1)IE,IE
1 FORMAT(A,'[H',A,'[J')
RETURN
END
FUNCTION ICMPST(STRING1,STRING2)
CHARACTER*128 STRING1,STRING2
C COMPARE TWO STRINGS, STOPPING ON NULL TERMINATORS
INTEGER*4 IRS
IRS=1
DO 100 I=1,128
IF(ICHAR(STRING1(I:I)).LE.32)GOTO 100
IF(ICHAR(STRING2(I:I)).LE.32)GOTO 100
IF(ICHAR(STRING1(I:I)).LE.0)GOTO 300
IF(ICHAR(STRING2(I:I)).LE.0)GOTO 300
IF(STRING1(I:I).NE.STRING2(I:I))GOTO 200
100 CONTINUE
GOTO 300
200 CONTINUE
IRS=0
300 CONTINUE
ICMPST=IRS
RETURN
END